package com.ny.view;

import com.ny.entity.Product;
import com.ny.entity.Stud;
import com.ny.service.ProductService;
import com.ny.service.StudentService;
import com.ny.service.impl.ProductServiceImpl;
import com.ny.service.impl.StudentServiceImpl;

import java.sql.SQLException;
import java.util.Scanner;

public class DeleteView {
    private StudentService uer2 = new StudentServiceImpl();

    public DeleteView() throws SQLException, ClassNotFoundException {
    }

    public void showDeleteForm() throws SQLException, ClassNotFoundException {
        System.out.println("请输入用户名：");
        Scanner scanner = new Scanner(System.in);
        String username = scanner.next();
        System.out.println("请输入密码：");
        String pwd = scanner.next();
        Stud stud = uer2.deleteStu(username, pwd);
        if (stud != null) {
            System.out.println("删除成功");
        }
    }

    private ProductService uer = new ProductServiceImpl();

    public void showDeleteProForm() throws SQLException, ClassNotFoundException {
        System.out.println("请输入要删除的商品名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.next();
        Product product = uer.deleteProduct(name);
        if (product == null) {
            System.out.println("删除成功");
        } else {
            System.out.println("删除失败");
        }
    }
}
